package cn.kgc.ffzw.day22.test;

public class Book {

    int id;
    String name;
    String author;
    double price;

    public Book(int id,String name,String author,double price){
        this.id=id;
        this.name=name;
        this.author=author;
        this.price=price;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public int hashCode() {
        String str = name + id;
        return str.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        Book book = (Book) obj;
        return name.equals(book.getName()) && (id==book.getId());
    }

    @Override
    public String toString() {
        return
                " 图书编号='" + this.getId() + '\'' +
                " 图书名='" + this.getName() + '\'' +
                " 图书作者='" + this.getAuthor() + '\''+
                " 图书价格='" + this.getPrice() + '\''+"\n";
    }
}
